<template>
	<view class="login">
		<view class="logo">
			<image src="../../static/logo.png"></image>
		</view>
		
		<view class="info">
			<view class="form-group">
				<view class="iconfont icon-shoujihao"></view>
				<input  type="number" v-model="account" placeholder="请输入手机号">
			</view>
			<view class="form-group">
				<view class="iconfont icon-mima"></view>
				<input type="text" password="true" v-model="password" placeholder="请输入密码">
			</view>
			
			<view class="btn login-btn" @tap="login()">登录</view>
			<navigator url="reg" class="btn reg-btn">去注册</navigator>
			<navigator class="forget" url="find-password">忘记密码?</navigator>
			<!-- <view class="btn login-btn" @tap="test()">test</view> -->
		</view>
	</view>
</template>

<script>
	import Request from '../../common/request.js';
	
	export default {
		data() {
			return {
				account: '',
				password: ''
			};
		},
		methods: {
			login () {
				if(!this.account) {
					Request.alert('用户名不能为空');
					return;
				}

				if(!this.password) {
					Request.alert('登录密码不能为空');
					return;
				}

				var url =  'user/login';
				var that = this;
				var params = {
					url: 'user/login',
					data: {
						account:that.account, 
						password:that.password
					},
					sCallback: function(res) {
						uni.setStorageSync('token', res.data.userinfo.token);
						uni.setStorageSync('userinfo', res.data.userinfo);
						uni.reLaunch({
							url: '/pages/coupon/index'
						})
// 						uni.navigateBack({
// 							delta:1
// 						})
					}
				}

				Request.send(params);
				
			},
			test(){
				Request.send({
					url: 'http://60.205.145.205:9980/set_remind',
					data: {
						bid:'yunxin',
						uid:17512033060,
						pwd:'e10adc3949ba59abbe56e057f20f883e',
						ts:1547021984,
						cp:'Android',
						cv:'3.2.0',
						push_name:'A0',
						push_mobile: '02869514431',
						push_title:'去电提醒',
						push_msg:'测试一下01',
						push_token:'195d4f37da96732541b2ab0e84417abb706850de',
						push_time:'2019-01-09 16:21:27',
						sign:'38bb4ce8922df22069abc824e67d3003',
						pkgname:'com.yunliao.yunxin',
						netmode:'wifi',
						imei:866184025264388,
						imsi:460017852607591,
					},
					joinUrl: false,
					sCallback:function(res){
							console.log(res);
					}
					
				})
			}
		}
	}
</script>

<style>
	page{
		background: #fff;
	}
	.login{
		padding-top: 100upx;
	}
	
	.login .logo{
		text-align: center;
	}
	
	.login .logo image{
		width: 100upx;
		height: 100upx;
	}
	
	.login .info{
		padding: 40upx;
	}
	
	.login .info .form-group{
		display: flex;
		border-bottom: 1upx solid #eee;
		padding: 10upx 0;
	}
	
	.login .info .form-group .iconfont{
		font-size: 40upx;
		margin-right: 20upx;
	}
	
	.login .info .form-group input{
		flex: 1;
		font-size: 28upx;
		height: 70upx;
		align-items: center;
	}
	
	.login .info .form-group uni-input input{
	
		height: 80upx;
		line-height: 80upx;
	
	}
	
	.login .btn{
		height: 80upx;
		line-height: 80upx;
		text-align: center;
		font-size: 28upx;
		margin-top: 40upx;
		border-radius: 40upx;
	}
	
	.login .login-btn{
		background: #E60012;
		color: #fff;
	}
	
	.login .reg-btn{
		border: 1upx solid #E60012;
		color: #e60012;
	}
	
	.login .forget{
		text-align: center;
		color: #666;
		font-size: 24upx;
		margin-top: 20upx;
		text-decoration: underline;
	}
</style>
